home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
util
/
libs
/
ppclibemu.lha
/
tests
/
objattr_demo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-20
|
2KB
|
63 lines
/*
* Shows all symbols of an ELF object by using PPCGetObjectAttrs()
*
* __reg("xx") is vbcc-specific. If you use another compiler you
* will have to change it.
*/
#include <exec/libraries.h>
#include <utility/tagitem.h>
#include <powerup/ppclib/object.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/ppc.h>
struct Library *PPCLibBase;
static void ScanHookFunc(__reg("a0")struct Hook *MyHook,
__reg("a2")void *MyElfStruct,
__reg("a1")struct PPCObjectInfo *MyInfo)
{
Printf("0x%08lx\t0x%08lx\t%s\n",
MyInfo->Address,
MyInfo->Size,
MyInfo->Name);
}
main(int argc,char *argv[])
{
if (argc != 2) {
Printf("Usage: %s <elf-object>\n",argv[0]);
exit(1);
}
if (PPCLibBase = OpenLibrary("ppc.library",46)) {
void *eo;
if (eo = PPCLoadObject(argv[1])) {
struct PPCObjectInfo MyInfo;
struct TagItem MyTags[2];
struct Hook MyScanSymbolHook;
MyScanSymbolHook.h_Entry = (ULONG (*)(void)) ScanHookFunc;
MyScanSymbolHook.h_SubEntry = (ULONG (*)(void)) NULL;
MyScanSymbolHook.h_Data = (APTR) PPCLibBase;
MyTags[0].ti_Tag = PPCELFINFOTAG_SCANSYMBOLHOOK;
MyTags[0].ti_Data = (ULONG)&MyScanSymbolHook;
MyTags[1].ti_Tag = TAG_END;
PPCGetObjectAttrs(eo,&MyInfo,MyTags);
PPCUnLoadObject(eo);
}
else
Printf("Can't load ELF object %s\n",argv[1]);
CloseLibrary(PPCLibBase);
}
else {
Printf("Can't open ppc.library V46!\n");
exit(1);
}
exit(0);
}